﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace VoiceAd
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute("LienHe", "lien-he.html", new { controller = "Home", action = "LienHe" });
            routes.MapRoute("AdminCp", "admincp.html", new { controller = "admincp", action = "index" });
            routes.MapRoute("KhachHang", "khach-hang.html", new { controller = "Customer", action = "Index" });
            routes.MapRoute("NhaDai", "nha-dai.html", new { controller = "Station", action = "Index" });
            routes.MapRoute("ReadContent", "service-{name}.html", new { controller = "Services", action = "index", name = (string)null });
            routes.MapRoute("Province", "province-{name}.html", new { controller = "admincp", action = "Province", name = (string)null });
            routes.MapRoute("District", "district-{name}.html", new { controller = "admincp", action = "District", name = (string)null });
            routes.MapRoute("Station", "station-{name}.html", new { controller = "admincp", action = "Station", name = (string)null });
            routes.MapRoute("BroadCast", "broadCast-{name}.html", new { controller = "admincp", action = "BroadCast", name = (string)null });
            routes.MapRoute("ListStation", "list-station-{id}-{name}.html", new { controller = "admincp", action = "ListStation", name = (string)null, id = (string)null });
            routes.MapRoute("Log", "log-{name}.html", new { controller = "admincp", action = "Log", name = (string)null });
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }
}